

import {
  publishApplication
} from '../../network/interface.js';
Page({
  onShareAppMessage() {
    return {
      title: 'form',
      path: 'page/component/pages/form/form'
    }
  },

  data: {

    pickerHidden: true,
    chosen: '',
    isOfferChecked:false,
    applyDate:'',
    acquireDate:'',
    inputSchoolname:"",
    inputMajor:"",
    inputSchool:"",
    inputGpa:"",
    inputBackGround:"",
    type:"",
    inputTuofu:'',
    inputYasi:'',
    academicDegree:""
  },

  pickerConfirm(e) {
    this.setData({
      pickerHidden: true
    })
    this.setData({
      chosen: e.detail.value
    })
  },

  pickerCancel() {
    this.setData({
      pickerHidden: true
    })
  },

  pickerShow() {
    this.setData({
      pickerHidden: false
    })
  },

  bindApplyDateChange: function(e) {
    this.setData({
      applyDate: e.detail.value
    })
  },

  bindAcquireDateChange: function(e) {
    this.setData({
      acquireDate: e.detail.value
    })
  },

  radioChange(e){
    this.setData({
      type:e.detail.value
    })
  },

  radioBenkeChange(e){
    this.setData({
      academicDegree:e.detail.value
    })
  },

  

  formSubmit(e) {
    console.log('form发生了submit事件，携带数据为：', e.detail.value)
  },

  formReset(e) {
    console.log('form发生了reset事件，携带数据为：', e.detail.value)
    this.setData({
      chosen: ''
    })
  },

  inputSchoolnameChange: function (e) {
    let text = e.detail.value;
    this.setData({
      inputSchoolname: text
    })
  },
  inputMajorChange: function (e) {
    let text = e.detail.value;
    this.setData({
      inputMajor: text
    })
  },
  inputSchoolChange: function (e) {
    let text = e.detail.value;
    this.setData({
      inputSchool: text
    })
  },
  inputGpaChange: function (e) {
    let text = e.detail.value;
    this.setData({
      inputGpa: text
    })
  },
  inputBackGroundChange: function (e) {
    let text = e.detail.value;
    this.setData({
      inputBackGround: text
    })
  },

  inputYasiChange: function (e) {
    let text = e.detail.value;
    this.setData({
      inputYasi: text
    })
  },

  inputTuofuChange: function (e) {
    let text = e.detail.value;
    this.setData({
      inputTuofu: text
    })
  },
  
  publish(){
    let params={};
    if (this.data.inputSchool == '') {
      wx.showToast({
        title: '请输入学校名称',
      })
      return
    }
    let userInfo = wx.getStorageSync('userInfo')
    if (userInfo==null) {
      wx.showToast({
        title: '未登录,不能发布哦',
      })
      
    }
    if (userInfo) {
      params.userId=userInfo.userId;
    }
    params.type=this.data.type;
    params.academicDegree=this.data.academicDegree;
    params.applyTime=this.data.applyDate;
    params.acquireTime=this.data.acquireDate;
    params.major=this.data.inputMajor;
    params.school=this.data.inputSchool;
    params.gpaScore=this.data.inputGpa;

    params.toeflScore=this.data.inputTuofu;
    params.ieltsScore=this.data.inputYasi;

    params.backGround=this.data.inputBackGround;
    console.log(params)
    publishApplication(params,function success(res) {
        if(res['status']==200){
         
          wx.reLaunch({
            url: '../../pages/index/index',
          })
          wx.showToast({
            title: '发布成功',
          })
        }
    },function fail(res) {
      
    })

  }
})